package com.ted.hole2;

import java.util.Arrays;
import java.util.List;

import com.ted.hole2.config.HoleService.EntityBuilder;
import com.ted.hole2.config.HoleService.Page;
import com.ted.hole2.model.User;
import com.ted.hole2.repository.UserRepository;

public class Application {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        UserRepository userService = UserRepository.get();
        userService.findByName(111L);
        userService.findByNickname("校长");
        userService.findPage(Page.newInstance(), new User().setId(1L));
        List<User> userList = userService.findList(User.query().allLike(User::getNickname, "小"));
        userList.forEach(u -> {
            System.out.println(u.getNickname());
        });

        userService.findByPrimaryKey(168738447945764865L);
        userService.findIn(new Long[] {168738447945764865L});

        userService.saveOrUpdate(EntityBuilder.get(User.class));
        userService.findList(User.query().equal(User::getAddress, "123"));

        userService.findList(User.query().select(Arrays.asList(User::getName)));

        userService.findList(User.query().selectExclude(User::getPassword));
    }

}
